﻿namespace ExamV5.PaperInfo
{
    using ExamV5;
    using System;
    using System.Configuration;
    using System.Data;
    using System.Data.SqlClient;
    using System.Threading;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public class FrmSetLastExam : Page
    {
        protected Button butClose;
        protected Button butEnter;
        protected CheckBox CBHandSet;
        protected DropDownList DDLEndH;
        protected DropDownList DDLEndM;
        protected DropDownList DDLStartH;
        protected DropDownList DDLStartM;
        protected HtmlForm form1;
        protected HtmlHead Head1;
        private HttpCookie httpCookie_0 = null;
        private HttpCookie httpCookie_1 = null;
        private HttpCookie httpCookie_2 = null;
        private HttpCookie httpCookie_3 = null;
        private int int_0 = 0;
        private PublicFun publicFun_0 = new PublicFun();
        protected RadioButtonList RBLAddType;
        protected RadioButtonList RBLExamShow;
        protected RadioButtonList RBLExamType;
        protected RadioButtonList RBLLastExamUser;
        protected ScriptManager SM;
        protected TextBox txtEndDate;
        protected TextBox txtEndIP;
        protected TextBox txtExamName;
        protected TextBox txtExamTime;
        protected TextBox txtStartDate;
        protected TextBox txtStartIP;
        protected TextBox txtUserList;
        protected UpdatePanel UPPart;

        protected void butEnter_Click(object sender, EventArgs e)
        {
            string[] strArray = this.txtStartIP.Text.Trim().Split(new char[] { '.' });
            string[] strArray2 = this.txtEndIP.Text.Trim().Split(new char[] { '.' });
            if (strArray.Length != 4)
            {
                ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCheck1", "alert('IP地址不合法！')", true);
            }
            else if (strArray2.Length != 4)
            {
                ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCheck1", "alert('IP地址不合法！')", true);
            }
            else
            {
                int num2;
                for (num2 = 0; num2 < strArray.Length; num2++)
                {
                    if ((((int.Parse(strArray[num2]) < 0) || (int.Parse(strArray[num2]) > 0xff)) || (int.Parse(strArray2[num2]) < 0)) || (int.Parse(strArray2[num2]) > 0xff))
                    {
                        ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCheck1", "alert('IP地址不合法！')", true);
                        return;
                    }
                }
                int sqlID = 0;
                string strSql = "";
                string str18 = this.txtStartDate.Text.Trim() + " " + this.DDLStartH.SelectedItem.Value + ":" + this.DDLStartM.SelectedItem.Value + ":00";
                string str19 = this.txtEndDate.Text.Trim() + " " + this.DDLEndH.SelectedItem.Value + ":" + this.DDLEndM.SelectedItem.Value + ":00";
                strSql = "insert into PaperInfo(EnterTime,SubjectID,JoinExamNum,IsShow,StartIP,EndIP,RubricTypeName,OutPutType,MemberFen,ExamName,SubjectName,PaperFen,PaperDiff,RubricDist,FenDist,MemoDist,ExamTime,PaperStartTime,PaperEndTime,IsCheck,CheckMan,Flag,PaperStatus,InputMan,InputUserCode,NoWriteFen,ErrorFen)";
                strSql = string.Concat(new object[] {
                    strSql, " select EnterTime,SubjectID,JoinExamNum,'", this.RBLExamShow.SelectedItem.Value, "','", this.txtStartIP.Text.Trim(), "','", this.txtEndIP.Text.Trim(), "',RubricTypeName,OutPutType,MemberFen,'", this.publicFun_0.CheckString(this.txtExamName.Text.Trim()), "',SubjectName,PaperFen,PaperDiff,RubricDist,FenDist,MemoDist,'", this.txtExamTime.Text.Trim(), "','", str18, "','", str19, "','N','',Flag,PaperStatus,'",
                    this.httpCookie_1.Value, "','", this.httpCookie_0.Value, "',NoWriteFen,ErrorFen  from PaperInfo where ID=", this.int_0
                 });
                sqlID = this.publicFun_0.GetSqlID(strSql);
                strSql = string.Concat(new object[] { "insert into GradeReule(ReuleName,MinValue,MaxValue,PaperID,StandFlag,StudyFen) select ReuleName,MinValue,MaxValue,", sqlID, ",StandFlag,StudyFen from GradeReule where PaperID=", this.int_0 });
                strSql = string.Concat(new object[] { strSql, ";insert into PaperRule(PaperID,RuleName,RuleValue,GetNum,GetPercNum,RubricType) select ", sqlID, ",RuleName,RuleValue,GetNum,GetPercNum,RubricType from PaperRule where PaperID=", this.int_0 });
                this.publicFun_0.ExecuteSql(strSql);
                string str9 = "";
                string str17 = "";
                string str6 = "";
                string str11 = "";
                string str5 = "";
                string str = "";
                string str15 = "A";
                SqlConnection connection2 = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
                connection2.Open();
                SqlCommand command2 = new SqlCommand("select a.PaperStatus,a.ExamName,a.RubricDist,a.SubjectID,a.SubjectName,a.PaperDiff,a.ExamTime from PaperInfo a where  a.ID=" + sqlID, connection2);
                SqlDataReader reader = command2.ExecuteReader(CommandBehavior.CloseConnection);
                if (reader.Read())
                {
                    str9 = reader["RubricDist"].ToString();
                    this.ViewState["strRubric"] = str9;
                    str17 = reader["SubjectID"].ToString();
                    str6 = reader["SubjectName"].ToString();
                    str11 = reader["PaperDiff"].ToString();
                    str5 = reader["ExamName"].ToString();
                    str = reader["ExamTime"].ToString();
                    str15 = reader["PaperStatus"].ToString();
                }
                reader.Close();
                command2.Dispose();
                connection2.Close();
                connection2.Dispose();
                string[] strArray6 = str17.Split(new char[] { ',' });
                string str10 = "";
                for (int i = 0; i < strArray6.Length; i++)
                {
                    if (str10.Trim().Length != 0)
                    {
                        str10 = str10 + " or SubjectID='" + strArray6[i].Trim() + "'";
                    }
                    else
                    {
                        str10 = "SubjectID='" + strArray6[i].Trim() + "'";
                    }
                }
                string str7 = "";
                if (!(this.publicFun_0.GetValues("select PaperID from PaperRule where PaperID=" + sqlID, "PaperID") != ""))
                {
                    str7 = "A";
                }
                else
                {
                    str7 = "B";
                }
                string str8 = "select ID from RubricInfo where IsDel='N' and Flag='" + str15 + "' and ISCheck='N' and (IsShare='A' or (IsShare='B' and CreatNumberNO='" + this.httpCookie_0.Value.Trim() + "'))";
                if (!(this.RBLAddType.SelectedItem.Value == "Y"))
                {
                    this.method_2(sqlID, str);
                }
                else
                {
                    SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
                    connection.Open();
                    SqlCommand command = new SqlCommand
                    {
                        Connection = connection
                    };
                    int num5 = 0;
                    if (!(str7.Trim() == "B"))
                    {
                        num5 = this.method_4(sqlID, str9.Trim(), str10, str11, str15);
                    }
                    else
                    {
                        num5 = this.method_3(sqlID, str8);
                    }
                    if (num5 == 0)
                    {
                        string str13 = "";
                        Random random = new Random();
                        string[] strArray5 = "Convert(varchar,OKAnswer)#Convert(varchar,OKAnswer) desc#ID#ID desc#RndNumber#RndNumber desc#SubjectID#SubjectID desc#RubricType".Split(new char[] { '#' });
                        string strUserCode = "";
                        string[] strArray3 = this.txtUserList.Text.Split(new char[] { ',' });
                        for (num2 = 0; num2 < strArray3.Length; num2++)
                        {
                            if (strArray3[num2].Trim() != "")
                            {
                                strUserCode = strArray3[num2].Substring(strArray3[num2].IndexOf("[") + 1).Replace("]", "");
                                if (this.RBLExamType.SelectedItem.Value != "A")
                                {
                                    if (this.RBLExamType.SelectedItem.Value != "B")
                                    {
                                        Thread.Sleep(1);
                                        if (str7.Trim() == "A")
                                        {
                                            this.method_5(sqlID, str9.Trim(), strUserCode.Trim(), str10, str11, "A");
                                        }
                                        if (str7.Trim() == "B")
                                        {
                                            this.method_6(sqlID, strUserCode.Trim(), str8, str9);
                                        }
                                    }
                                    else
                                    {
                                        Thread.Sleep(1);
                                        string str12 = "";
                                        for (int j = 0; j < 3; j++)
                                        {
                                            int index = random.Next(strArray5.Length - 1);
                                            str12 = str12 + strArray5[index] + "#";
                                        }
                                        str13 = str12 + "ID#ID#ID#ID#ID#ID#ID";
                                        strSql = "Insert into PaperData(PaperID,UserCode,RubricS,RubricD,RubricB,RubricF,RubricA,RubricC,RubricT,RubricAN,RubricO,RubricJ,SortInfo) ";
                                        strSql = string.Concat(new object[] { strSql, " select PaperID,'", strUserCode.Trim(), "' as UserCode,RubricS,RubricD,RubricB,RubricF,RubricA,RubricC,RubricT,RubricAN,RubricO,RubricJ,'", str13, "' as SortInfo from PaperDataTmp where PaperID=", sqlID });
                                        command.CommandText = strSql;
                                        command.ExecuteNonQuery();
                                    }
                                }
                                else
                                {
                                    str13 = "ID#ID#ID#ID#ID#ID#ID#ID#ID#ID";
                                    strSql = "Insert into PaperData(PaperID,UserCode,RubricS,RubricD,RubricB,RubricF,RubricA,RubricC,RubricT,RubricAN,RubricO,RubricJ,SortInfo) ";
                                    strSql = string.Concat(new object[] { strSql, " select ", sqlID, ",'", strUserCode.Trim(), "' as UserCode,RubricS,RubricD,RubricB,RubricF,RubricA,RubricC,RubricT,RubricAN,RubricO,RubricJ,'", str13, "' as SortInfo from PaperDataTmp where PaperID=", sqlID });
                                    command.CommandText = strSql;
                                    command.ExecuteNonQuery();
                                }
                                command.CommandText = string.Concat(new object[] { "Insert into ExamUser(UserCode,PaperID,ExamName,Subject,GetOldCountFen,GetCountFen,ExamType,Flag,LastTime) values('", strUserCode.Trim(), "',", sqlID, ",'", str5, "','", str6, "','0','0','A','A','", str, "')" });
                                command.ExecuteNonQuery();
                                string str4 = "您有最新的补考信息！";
                                if (this.CBHandSet.Checked)
                                {
                                    this.publicFun_0.SendHandSet(strUserCode, "考试系统提醒：" + str4, this.httpCookie_1.Value, this.httpCookie_0.Value);
                                }
                            }
                        }
                        this.publicFun_0.ExecuteSql("insert into SysLogInfo(LogDisp,EditUser,EditUserCode) values('补考试卷-随机组卷且试卷生成成功！','" + this.httpCookie_1.Value + "','" + this.httpCookie_0.Value + "')");
                        ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BSucc", "alert('补考试卷-随机组卷且试卷生成成功！');window.opener.location.reload();window.close();", true);
                    }
                    else
                    {
                        strSql = string.Concat(new object[] { "delete from PaperDataTmp where PaperID=", sqlID, ";delete from PaperData where PaperID=", sqlID, ";delete from GradeReule where PaperID=", sqlID, ";Delete from PaperInfo where ID=", sqlID, ";delete from SysTip where  Formtable='PaperInfo' and FormID=", sqlID });
                        this.publicFun_0.ExecuteSql(strSql);
                        ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BSucc", "alert('新建补考试卷信息失败！');", true);
                    }
                    connection.Close();
                    connection.Dispose();
                }
            }
        }

        private void method_0()
        {
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            connection.Open();
            SqlCommand command = new SqlCommand("select ExamName,ExamTime,StartIP,EndIP,IsShow from PaperInfo where ID=" + this.int_0, connection);
            SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
            if (reader.Read())
            {
                this.txtExamName.Text = reader["ExamName"].ToString() + "（补考）";
                this.txtExamTime.Text = reader["ExamTime"].ToString();
                this.txtStartIP.Text = reader["StartIP"].ToString();
                this.txtEndIP.Text = reader["EndIP"].ToString();
                this.RBLExamShow.SelectedIndex = -1;
                this.RBLExamShow.Items.FindByValue(reader["IsShow"].ToString()).Selected = true;
            }
            reader.Close();
            command.Dispose();
            connection.Close();
            connection.Dispose();
        }

        private void method_1()
        {
            this.txtUserList.Text = "";
            string str = this.RBLLastExamUser.SelectedItem.Value;
            string strSql = "";
            string values = this.publicFun_0.GetValues("select MaxValue from GradeReule where PaperID=" + this.int_0 + " and StandFlag='D'", "MaxValue");
            if (values.Trim() == "")
            {
                values = "59.9";
            }
            if ((str != "") && !(str == "Y"))
            {
                if (!(str == "N"))
                {
                    strSql = string.Concat(new object[] { "select b.UserName+'['+a.UserCode+']' from ExamUser a,UserInfo b where a.UserCode=b.UserCode and  a.PaperID=", this.int_0, " and ((a.Flag='E' and a.GetCountFen<=", values, ") or a.Flag='A')" });
                }
                else
                {
                    strSql = "select b.UserName+'['+a.UserCode+']' from ExamUser a,UserInfo b where a.UserCode=b.UserCode and  a.PaperID=" + this.int_0 + " and a.Flag='A'";
                }
            }
            else
            {
                strSql = string.Concat(new object[] { "select b.UserName+'['+a.UserCode+']' from ExamUser a,UserInfo b where a.UserCode=b.UserCode and  a.PaperID=", this.int_0, " and a.Flag='E' and a.GetCountFen<=", values });
            }
            this.txtUserList.Text = this.publicFun_0.GetValues(strSql);
            if (this.txtUserList.Text.Length > 1)
            {
                this.txtUserList.Text = this.txtUserList.Text.Substring(0, this.txtUserList.Text.Length - 1);
            }
        }

        private void method_2(int int_1, string string_0)
        {
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            connection.Open();
            SqlCommand command = new SqlCommand
            {
                Connection = connection
            };
            string str2 = "";
            string strUserCode = "";
            string[] strArray = this.txtUserList.Text.Split(new char[] { ',' });
            for (int i = 0; i < strArray.Length; i++)
            {
                if (strArray[i].Trim() != "")
                {
                    string str4 = "您有最新的补考信息！";
                    strUserCode = strArray[i].Substring(strArray[i].IndexOf("[") + 1).Replace("]", "");
                    str2 = "Insert into PaperData(PaperID,UserCode,RubricS,RubricD,RubricB,RubricF,RubricA,RubricC,RubricT,RubricAN,RubricO,RubricJ,SortInfo) ";
                    str2 = string.Concat(new object[] { str2, " select ", int_1, ",'", strUserCode.Trim(), "' as UserCode,RubricS,RubricD,RubricB,RubricF,RubricA,RubricC,RubricT,RubricAN,RubricO,RubricJ,SortInfo from PaperData where UserCode='", strUserCode.Trim(), "' and PaperID=", this.int_0 });
                    str2 = string.Concat(new object[] { str2, ";Insert into ExamUser(UserCode,PaperID,ExamName,Subject,GetOldCountFen,GetCountFen,ExamType,Flag,LastTime) select '", strUserCode.Trim(), "',", int_1, ",'", this.txtExamName.Text.Trim(), "',Subject,'0','0',ExamType,'A','", string_0, "' from ExamUser where  UserCode='", strUserCode.Trim(), "' and PaperID=", this.int_0 });
                    command.CommandText = str2;
                    command.ExecuteNonQuery();
                    if (this.CBHandSet.Checked)
                    {
                        this.publicFun_0.SendHandSet(strUserCode, "考试系统提醒：" + str4, this.httpCookie_1.Value, this.httpCookie_0.Value);
                    }
                }
            }
            this.publicFun_0.ExecuteSql("insert into SysLogInfo(LogDisp,EditUser,EditUserCode) values('补考试卷-随机组卷且试卷生成成功！','" + this.httpCookie_1.Value + "','" + this.httpCookie_0.Value + "')");
            ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BSucc", "alert('补考试卷-随机组卷且试卷生成成功！');window.opener.location.reload();window.close();", true);
            connection.Close();
            connection.Dispose();
        }

        private int method_3(int int_1, string string_0)
        {
            SqlDataReader reader;
            SqlCommand command;
            SqlConnection connection2;
            string str14;
            int count;
            int num5;
            string str = "#";
            string str2 = "#";
            string str3 = "#";
            string str4 = "#";
            string str5 = "#";
            string str6 = "#";
            string str7 = "#";
            string str8 = "#";
            string str9 = "#";
            Random random = new Random();
            bool flag = true;
            string str10 = "";
            int num2 = 0;
            string[] strArray = this.ViewState["strRubric"].ToString().Split(new char[] { '#' });
            string strSql = "";
            string connectionString = ConfigurationManager.ConnectionStrings["Conn"].ConnectionString;
            SqlConnection selectConnection = new SqlConnection(connectionString);
            DataSet dataSet = new DataSet();
            if (Convert.ToInt32(strArray[0]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='A'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter9 = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num2 = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter9 = new SqlDataAdapter(string_0 + "  and (" + str10 + ")", selectConnection);
                    adapter9.Fill(dataSet, "AExamData");
                    count = dataSet.Tables["AExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num2 == 0)
                        {
                            break;
                        }
                        num5 = random.Next(count);
                        str14 = dataSet.Tables["AExamData"].Rows[num5]["ID"].ToString() + "#";
                        if (str.IndexOf("#" + str14, 0) == -1)
                        {
                            str = str + str14;
                            num2--;
                        }
                    }
                    adapter9.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            if (Convert.ToInt32(strArray[1]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='B'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter8 = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num2 = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter8 = new SqlDataAdapter(string_0 + " and (" + str10 + ")", selectConnection);
                    adapter8.Fill(dataSet, "BExamData");
                    count = dataSet.Tables["BExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num2 == 0)
                        {
                            break;
                        }
                        num5 = random.Next(count);
                        str14 = dataSet.Tables["BExamData"].Rows[num5]["ID"].ToString() + "#";
                        if (str2.IndexOf("#" + str14, 0) == -1)
                        {
                            str2 = str2 + str14;
                            num2--;
                        }
                    }
                    adapter8.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            if (Convert.ToInt32(strArray[2]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='C'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter7 = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num2 = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter7 = new SqlDataAdapter(string_0 + " and (" + str10 + ")", selectConnection);
                    adapter7.Fill(dataSet, "CExamData");
                    count = dataSet.Tables["CExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num2 == 0)
                        {
                            break;
                        }
                        num5 = random.Next(count);
                        str14 = dataSet.Tables["CExamData"].Rows[num5]["ID"].ToString() + "#";
                        if (str3.IndexOf("#" + str14, 0) == -1)
                        {
                            str3 = str3 + str14;
                            num2--;
                        }
                    }
                    adapter7.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            if (Convert.ToInt32(strArray[3]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='D'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter6 = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num2 = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter6 = new SqlDataAdapter(string_0 + " and (" + str10 + ")", selectConnection);
                    adapter6.Fill(dataSet, "DExamData");
                    count = dataSet.Tables["DExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num2 == 0)
                        {
                            break;
                        }
                        num5 = random.Next(count);
                        str14 = dataSet.Tables["DExamData"].Rows[num5]["ID"].ToString() + "#";
                        if (str4.IndexOf("#" + str14, 0) == -1)
                        {
                            str4 = str4 + str14;
                            num2--;
                        }
                    }
                    adapter6.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            if (Convert.ToInt32(strArray[4]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='E'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter5 = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num2 = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter5 = new SqlDataAdapter(string_0 + " and (" + str10 + ")", selectConnection);
                    adapter5.Fill(dataSet, "EExamData");
                    count = dataSet.Tables["EExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num2 == 0)
                        {
                            break;
                        }
                        num5 = random.Next(count);
                        str14 = dataSet.Tables["EExamData"].Rows[num5]["ID"].ToString() + "#";
                        if (str5.IndexOf("#" + str14, 0) == -1)
                        {
                            str5 = str5 + str14;
                            num2--;
                        }
                    }
                    adapter5.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            if (Convert.ToInt32(strArray[5]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='F'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter4 = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num2 = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter4 = new SqlDataAdapter(string_0 + " and (" + str10 + ")", selectConnection);
                    adapter4.Fill(dataSet, "FExamData");
                    count = dataSet.Tables["FExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num2 == 0)
                        {
                            break;
                        }
                        num5 = random.Next(count);
                        str14 = dataSet.Tables["FExamData"].Rows[num5]["ID"].ToString() + "#";
                        if (str6.IndexOf("#" + str14, 0) == -1)
                        {
                            str6 = str6 + str14;
                            num2--;
                        }
                    }
                    adapter4.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            if (Convert.ToInt32(strArray[6]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='G'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter3 = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num2 = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter3 = new SqlDataAdapter(string_0 + " and (" + str10 + ")", selectConnection);
                    adapter3.Fill(dataSet, "GExamData");
                    count = dataSet.Tables["GExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num2 == 0)
                        {
                            break;
                        }
                        num5 = random.Next(count);
                        str14 = dataSet.Tables["GExamData"].Rows[num5]["ID"].ToString() + "#";
                        if (str7.IndexOf("#" + str14, 0) == -1)
                        {
                            str7 = str7 + str14;
                            num2--;
                        }
                    }
                    adapter3.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            if (Convert.ToInt32(strArray[7]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='H'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter2 = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num2 = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter2 = new SqlDataAdapter(string_0 + " and (" + str10 + ")", selectConnection);
                    adapter2.Fill(dataSet, "HExamData");
                    count = dataSet.Tables["HExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num2 == 0)
                        {
                            break;
                        }
                        num5 = random.Next(count);
                        str14 = dataSet.Tables["HExamData"].Rows[num5]["ID"].ToString() + "#";
                        if (str8.IndexOf("#" + str14, 0) == -1)
                        {
                            str8 = str8 + str14;
                            num2--;
                        }
                    }
                    adapter2.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            if (Convert.ToInt32(strArray[8]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='I'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num2 = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter = new SqlDataAdapter(string_0 + " and (" + str10 + ")", selectConnection);
                    adapter.Fill(dataSet, "IExamData");
                    count = dataSet.Tables["IExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num2 == 0)
                        {
                            break;
                        }
                        num5 = random.Next(count);
                        str14 = dataSet.Tables["IExamData"].Rows[num5]["ID"].ToString() + "#";
                        if (str9.IndexOf("#" + str14, 0) == -1)
                        {
                            str9 = str9 + str14;
                            num2--;
                        }
                    }
                    adapter.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            dataSet.Clear();
            dataSet.Dispose();
            selectConnection.Close();
            selectConnection.Dispose();
            string values = this.publicFun_0.GetValues("select top 1 RubricJ from PaperData where PaperID=" + this.int_0, "RubricJ");
            if (!(values != ""))
            {
                values = "";
            }
            else
            {
                values = values.Trim().Replace("_", "#");
            }
            if (str.Length <= 1)
            {
                str = "";
            }
            else
            {
                str = str.Substring(1);
            }
            if (str2.Length <= 1)
            {
                str2 = "";
            }
            else
            {
                str2 = str2.Substring(1);
            }
            if (str3.Length <= 1)
            {
                str3 = "";
            }
            else
            {
                str3 = str3.Substring(1);
            }
            if (str4.Length > 1)
            {
                str4 = str4.Substring(1);
            }
            else
            {
                str4 = "";
            }
            if (str5.Length <= 1)
            {
                str5 = "";
            }
            else
            {
                str5 = str5.Substring(1);
            }
            if (str6.Length <= 1)
            {
                str6 = "";
            }
            else
            {
                str6 = str6.Substring(1);
            }
            if (str7.Length <= 1)
            {
                str7 = "";
            }
            else
            {
                str7 = str7.Substring(1);
            }
            if (str8.Length > 1)
            {
                str8 = str8.Substring(1);
            }
            else
            {
                str8 = "";
            }
            if (str9.Length > 1)
            {
                str9 = str9.Substring(1);
            }
            else
            {
                str9 = "";
            }
            try
            {
                strSql = string.Concat(new object[] { "delete from PaperDataTmp where PaperID=", int_1, ";Insert into PaperDataTmp(PaperID,RubricS,RubricD,RubricB,RubricF,RubricA,RubricC,RubricT,RubricAN,RubricO,RubricJ) values(", int_1 });
                strSql = strSql + ",'" + str + "','" + str2 + "','" + str3 + "','" + str4 + "','" + str5 + "','" + str6 + "','" + str7 + "','" + str8 + "','" + str9 + "','" + values + "')";
                this.publicFun_0.ExecuteSql(strSql);
                return 0;
            }
            catch
            {
                return 1;
            }
        }

        private int method_4(int int_1, string string_0, string string_1, string string_2, string string_3)
        {
            string str = "#";
            string str2 = "#";
            string str3 = "#";
            string str4 = "#";
            string str5 = "#";
            string str6 = "#";
            string str7 = "#";
            string str8 = "#";
            string str9 = "#";
            Random random = new Random();
            bool flag = true;
            string[] strArray = string_0.Split(new char[] { '#' });
            string str10 = string_3;
            string strSql = ("select ID from RubricInfo where Flag='" + str10 + "' and ISCheck='N' and (" + string_1 + ") and IsDel='N' ") + "  and (IsShare='A' or (IsShare='B' and CreatNumberNO='" + this.httpCookie_0.Value.Trim() + "'))";
            SqlConnection selectConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            DataSet dataSet = new DataSet();
            if (Convert.ToInt32(strArray[0]) > 0)
            {
                int num27 = Convert.ToInt32(strArray[0]);
                SqlDataAdapter adapter9 = new SqlDataAdapter(strSql + " and RubricType='A'", selectConnection);
                adapter9.Fill(dataSet, "AExamData");
                int count = dataSet.Tables["AExamData"].Rows.Count;
                while (flag)
                {
                    if (num27 == 0)
                    {
                        break;
                    }
                    int num29 = random.Next(count);
                    string str30 = dataSet.Tables["AExamData"].Rows[num29]["ID"].ToString() + "#";
                    if (str.IndexOf("#" + str30, 0) == -1)
                    {
                        str = str + str30;
                        num27--;
                    }
                }
                dataSet.Tables.Clear();
                adapter9.Dispose();
            }
            if (Convert.ToInt32(strArray[1]) > 0)
            {
                int num24 = Convert.ToInt32(strArray[1]);
                SqlDataAdapter adapter8 = new SqlDataAdapter(strSql + " and RubricType='B'", selectConnection);
                adapter8.Fill(dataSet, "BExamData");
                int maxValue = dataSet.Tables["BExamData"].Rows.Count;
                while (flag)
                {
                    if (num24 == 0)
                    {
                        break;
                    }
                    int num26 = random.Next(maxValue);
                    string str28 = dataSet.Tables["BExamData"].Rows[num26]["ID"].ToString() + "#";
                    if (str2.IndexOf("#" + str28, 0) == -1)
                    {
                        str2 = str2 + str28;
                        num24--;
                    }
                }
                dataSet.Tables.Clear();
                adapter8.Dispose();
            }
            if (Convert.ToInt32(strArray[2]) > 0)
            {
                int num21 = Convert.ToInt32(strArray[2]);
                SqlDataAdapter adapter7 = new SqlDataAdapter(strSql + " and RubricType='C'", selectConnection);
                adapter7.Fill(dataSet, "CExamData");
                int num22 = dataSet.Tables["CExamData"].Rows.Count;
                while (flag)
                {
                    if (num21 == 0)
                    {
                        break;
                    }
                    int num23 = random.Next(num22);
                    string str26 = dataSet.Tables["CExamData"].Rows[num23]["ID"].ToString() + "#";
                    if (str3.IndexOf("#" + str26, 0) == -1)
                    {
                        str3 = str3 + str26;
                        num21--;
                    }
                }
                dataSet.Tables.Clear();
                adapter7.Dispose();
            }
            if (Convert.ToInt32(strArray[3]) > 0)
            {
                int num18 = Convert.ToInt32(strArray[3]);
                SqlDataAdapter adapter6 = new SqlDataAdapter(strSql + " and RubricType='D'", selectConnection);
                adapter6.Fill(dataSet, "DExamData");
                int num19 = dataSet.Tables["DExamData"].Rows.Count;
                while (flag)
                {
                    if (num18 == 0)
                    {
                        break;
                    }
                    int num20 = random.Next(num19);
                    string str24 = dataSet.Tables["DExamData"].Rows[num20]["ID"].ToString() + "#";
                    if (str4.IndexOf("#" + str24, 0) == -1)
                    {
                        str4 = str4 + str24;
                        num18--;
                    }
                }
                dataSet.Tables.Clear();
                adapter6.Dispose();
            }
            if (Convert.ToInt32(strArray[4]) > 0)
            {
                int num15 = Convert.ToInt32(strArray[4]);
                SqlDataAdapter adapter5 = new SqlDataAdapter(strSql + " and RubricType='E'", selectConnection);
                adapter5.Fill(dataSet, "EExamData");
                int num16 = dataSet.Tables["EExamData"].Rows.Count;
                while (flag)
                {
                    if (num15 == 0)
                    {
                        break;
                    }
                    int num17 = random.Next(num16);
                    string str22 = dataSet.Tables["EExamData"].Rows[num17]["ID"].ToString() + "#";
                    if (str5.IndexOf("#" + str22, 0) == -1)
                    {
                        str5 = str5 + str22;
                        num15--;
                    }
                }
                dataSet.Tables.Clear();
                adapter5.Dispose();
            }
            if (Convert.ToInt32(strArray[5]) > 0)
            {
                int num12 = Convert.ToInt32(strArray[5]);
                SqlDataAdapter adapter4 = new SqlDataAdapter(strSql + " and RubricType='F'", selectConnection);
                adapter4.Fill(dataSet, "FExamData");
                int num13 = dataSet.Tables["FExamData"].Rows.Count;
                while (flag)
                {
                    if (num12 == 0)
                    {
                        break;
                    }
                    int num14 = random.Next(num13);
                    string str20 = dataSet.Tables["FExamData"].Rows[num14]["ID"].ToString() + "#";
                    if (str6.IndexOf("#" + str20, 0) == -1)
                    {
                        str6 = str6 + str20;
                        num12--;
                    }
                }
                dataSet.Tables.Clear();
                adapter4.Dispose();
            }
            if (Convert.ToInt32(strArray[6]) > 0)
            {
                int num9 = Convert.ToInt32(strArray[6]);
                SqlDataAdapter adapter3 = new SqlDataAdapter(strSql + " and RubricType='G'", selectConnection);
                adapter3.Fill(dataSet, "GExamData");
                int num10 = dataSet.Tables["GExamData"].Rows.Count;
                while (flag)
                {
                    if (num9 == 0)
                    {
                        break;
                    }
                    int num11 = random.Next(num10);
                    string str18 = dataSet.Tables["GExamData"].Rows[num11]["ID"].ToString() + "#";
                    if (str7.IndexOf("#" + str18, 0) == -1)
                    {
                        str7 = str7 + str18;
                        num9--;
                    }
                }
                dataSet.Tables.Clear();
                adapter3.Dispose();
            }
            if (Convert.ToInt32(strArray[7]) > 0)
            {
                int num6 = Convert.ToInt32(strArray[7]);
                SqlDataAdapter adapter2 = new SqlDataAdapter(strSql + " and RubricType='H'", selectConnection);
                adapter2.Fill(dataSet, "HExamData");
                int num7 = dataSet.Tables["HExamData"].Rows.Count;
                while (flag)
                {
                    if (num6 == 0)
                    {
                        break;
                    }
                    int num8 = random.Next(num7);
                    string str16 = dataSet.Tables["HExamData"].Rows[num8]["ID"].ToString() + "#";
                    if (str8.IndexOf("#" + str16, 0) == -1)
                    {
                        str8 = str8 + str16;
                        num6--;
                    }
                }
                dataSet.Tables.Clear();
                adapter2.Dispose();
            }
            if (Convert.ToInt32(strArray[8]) > 0)
            {
                int num3 = Convert.ToInt32(strArray[8]);
                SqlDataAdapter adapter = new SqlDataAdapter(strSql + " and RubricType='I'", selectConnection);
                adapter.Fill(dataSet, "IExamData");
                int num4 = dataSet.Tables["IExamData"].Rows.Count;
                while (flag)
                {
                    if (num3 == 0)
                    {
                        break;
                    }
                    int num5 = random.Next(num4);
                    string str14 = dataSet.Tables["IExamData"].Rows[num5]["ID"].ToString() + "#";
                    if (str9.IndexOf("#" + str14, 0) == -1)
                    {
                        str9 = str9 + str14;
                        num3--;
                    }
                }
                dataSet.Tables.Clear();
                adapter.Dispose();
            }
            dataSet.Clear();
            dataSet.Dispose();
            selectConnection.Close();
            selectConnection.Dispose();
            string values = this.publicFun_0.GetValues("select top 1 RubricJ from PaperData where PaperID=" + int_1, "RubricJ");
            if (values != "")
            {
                values = values.Trim().Replace("_", "#");
            }
            else
            {
                values = "";
            }
            if (str.Length > 1)
            {
                str = str.Substring(1);
            }
            else
            {
                str = "";
            }
            if (str2.Length <= 1)
            {
                str2 = "";
            }
            else
            {
                str2 = str2.Substring(1);
            }
            if (str3.Length > 1)
            {
                str3 = str3.Substring(1);
            }
            else
            {
                str3 = "";
            }
            if (str4.Length > 1)
            {
                str4 = str4.Substring(1);
            }
            else
            {
                str4 = "";
            }
            if (str5.Length <= 1)
            {
                str5 = "";
            }
            else
            {
                str5 = str5.Substring(1);
            }
            if (str6.Length <= 1)
            {
                str6 = "";
            }
            else
            {
                str6 = str6.Substring(1);
            }
            if (str7.Length <= 1)
            {
                str7 = "";
            }
            else
            {
                str7 = str7.Substring(1);
            }
            if (str8.Length <= 1)
            {
                str8 = "";
            }
            else
            {
                str8 = str8.Substring(1);
            }
            if (str9.Length > 1)
            {
                str9 = str9.Substring(1);
            }
            else
            {
                str9 = "";
            }
            strSql = "Insert into PaperDataTmp(PaperID,RubricS,RubricD,RubricB,RubricF,RubricA,RubricC,RubricT,RubricAN,RubricO,RubricJ) values(" + int_1;
            strSql = strSql + ",'" + str + "','" + str2 + "','" + str3 + "','" + str4 + "','" + str5 + "','" + str6 + "','" + str7 + "','" + str8 + "','" + str9 + "','" + values + "')";
            if (this.publicFun_0.ExecuteSql(strSql) == 0)
            {
                return 1;
            }
            return 0;
        }

        private void method_5(int int_1, string string_0, string string_1, string string_2, string string_3, string string_4)
        {
            string str = "#";
            string str2 = "#";
            string str3 = "#";
            string str4 = "#";
            string str5 = "#";
            string str6 = "#";
            string str7 = "#";
            string str8 = "#";
            string str9 = "#";
            Random random = new Random();
            bool flag = true;
            string[] strArray = string_0.Split(new char[] { '#' });
            string str10 = string_4;
            string strSql = "select ID from RubricInfo where IsDel='N' and Flag='" + str10 + "' and ISCheck='N' and (" + string_2 + ") and (IsShare='A' or (IsShare='B' and CreatNumberNO='" + this.httpCookie_0.Value.Trim() + "'))";
            SqlConnection selectConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            DataSet dataSet = new DataSet();
            if (Convert.ToInt32(strArray[0]) > 0)
            {
                int num25 = Convert.ToInt32(strArray[0]);
                SqlDataAdapter adapter9 = new SqlDataAdapter(strSql + " and RubricType='A'", selectConnection);
                adapter9.Fill(dataSet, "AExamData");
                int count = dataSet.Tables["AExamData"].Rows.Count;
                while (flag)
                {
                    if (num25 == 0)
                    {
                        break;
                    }
                    int num27 = random.Next(count);
                    string str30 = dataSet.Tables["AExamData"].Rows[num27]["ID"].ToString() + "#";
                    if (str.IndexOf("#" + str30, 0) == -1)
                    {
                        str = str + str30;
                        num25--;
                    }
                }
                dataSet.Tables.Clear();
                adapter9.Dispose();
            }
            if (Convert.ToInt32(strArray[1]) > 0)
            {
                int num22 = Convert.ToInt32(strArray[1]);
                SqlDataAdapter adapter8 = new SqlDataAdapter(strSql + " and RubricType='B'", selectConnection);
                adapter8.Fill(dataSet, "BExamData");
                int maxValue = dataSet.Tables["BExamData"].Rows.Count;
                while (flag)
                {
                    if (num22 == 0)
                    {
                        break;
                    }
                    int num24 = random.Next(maxValue);
                    string str28 = dataSet.Tables["BExamData"].Rows[num24]["ID"].ToString() + "#";
                    if (str2.IndexOf("#" + str28, 0) == -1)
                    {
                        str2 = str2 + str28;
                        num22--;
                    }
                }
                dataSet.Tables.Clear();
                adapter8.Dispose();
            }
            if (Convert.ToInt32(strArray[2]) > 0)
            {
                int num19 = Convert.ToInt32(strArray[2]);
                SqlDataAdapter adapter7 = new SqlDataAdapter(strSql + " and RubricType='C'", selectConnection);
                adapter7.Fill(dataSet, "CExamData");
                int num20 = dataSet.Tables["CExamData"].Rows.Count;
                while (flag)
                {
                    if (num19 == 0)
                    {
                        break;
                    }
                    int num21 = random.Next(num20);
                    string str26 = dataSet.Tables["CExamData"].Rows[num21]["ID"].ToString() + "#";
                    if (str3.IndexOf("#" + str26, 0) == -1)
                    {
                        str3 = str3 + str26;
                        num19--;
                    }
                }
                dataSet.Tables.Clear();
                adapter7.Dispose();
            }
            if (Convert.ToInt32(strArray[3]) > 0)
            {
                int num16 = Convert.ToInt32(strArray[3]);
                SqlDataAdapter adapter6 = new SqlDataAdapter(strSql + " and RubricType='D'", selectConnection);
                adapter6.Fill(dataSet, "DExamData");
                int num17 = dataSet.Tables["DExamData"].Rows.Count;
                while (flag)
                {
                    if (num16 == 0)
                    {
                        break;
                    }
                    int num18 = random.Next(num17);
                    string str24 = dataSet.Tables["DExamData"].Rows[num18]["ID"].ToString() + "#";
                    if (str4.IndexOf("#" + str24, 0) == -1)
                    {
                        str4 = str4 + str24;
                        num16--;
                    }
                }
                dataSet.Tables.Clear();
                adapter6.Dispose();
            }
            if (Convert.ToInt32(strArray[4]) > 0)
            {
                int num13 = Convert.ToInt32(strArray[4]);
                SqlDataAdapter adapter5 = new SqlDataAdapter(strSql + " and RubricType='E'", selectConnection);
                adapter5.Fill(dataSet, "EExamData");
                int num14 = dataSet.Tables["EExamData"].Rows.Count;
                while (flag)
                {
                    if (num13 == 0)
                    {
                        break;
                    }
                    int num15 = random.Next(num14);
                    string str22 = dataSet.Tables["EExamData"].Rows[num15]["ID"].ToString() + "#";
                    if (str5.IndexOf("#" + str22, 0) == -1)
                    {
                        str5 = str5 + str22;
                        num13--;
                    }
                }
                dataSet.Tables.Clear();
                adapter5.Dispose();
            }
            if (Convert.ToInt32(strArray[5]) > 0)
            {
                int num10 = Convert.ToInt32(strArray[5]);
                SqlDataAdapter adapter4 = new SqlDataAdapter(strSql + " and RubricType='F'", selectConnection);
                adapter4.Fill(dataSet, "FExamData");
                int num11 = dataSet.Tables["FExamData"].Rows.Count;
                while (flag)
                {
                    if (num10 == 0)
                    {
                        break;
                    }
                    int num12 = random.Next(num11);
                    string str20 = dataSet.Tables["FExamData"].Rows[num12]["ID"].ToString() + "#";
                    if (str6.IndexOf("#" + str20, 0) == -1)
                    {
                        str6 = str6 + str20;
                        num10--;
                    }
                }
                dataSet.Tables.Clear();
                adapter4.Dispose();
            }
            if (Convert.ToInt32(strArray[6]) > 0)
            {
                int num7 = Convert.ToInt32(strArray[6]);
                SqlDataAdapter adapter3 = new SqlDataAdapter(strSql + " and RubricType='G'", selectConnection);
                adapter3.Fill(dataSet, "GExamData");
                int num8 = dataSet.Tables["GExamData"].Rows.Count;
                while (flag)
                {
                    if (num7 == 0)
                    {
                        break;
                    }
                    int num9 = random.Next(num8);
                    string str18 = dataSet.Tables["GExamData"].Rows[num9]["ID"].ToString() + "#";
                    if (str7.IndexOf("#" + str18, 0) == -1)
                    {
                        str7 = str7 + str18;
                        num7--;
                    }
                }
                dataSet.Tables.Clear();
                adapter3.Dispose();
            }
            if (Convert.ToInt32(strArray[7]) > 0)
            {
                int num4 = Convert.ToInt32(strArray[7]);
                SqlDataAdapter adapter2 = new SqlDataAdapter(strSql + " and RubricType='H'", selectConnection);
                adapter2.Fill(dataSet, "HExamData");
                int num5 = dataSet.Tables["HExamData"].Rows.Count;
                while (flag)
                {
                    if (num4 == 0)
                    {
                        break;
                    }
                    int num6 = random.Next(num5);
                    string str16 = dataSet.Tables["HExamData"].Rows[num6]["ID"].ToString() + "#";
                    if (str8.IndexOf("#" + str16, 0) == -1)
                    {
                        str8 = str8 + str16;
                        num4--;
                    }
                }
                dataSet.Tables.Clear();
                adapter2.Dispose();
            }
            if (Convert.ToInt32(strArray[8]) > 0)
            {
                int num = Convert.ToInt32(strArray[8]);
                SqlDataAdapter adapter = new SqlDataAdapter(strSql + " and RubricType='I'", selectConnection);
                adapter.Fill(dataSet, "IExamData");
                int num2 = dataSet.Tables["IExamData"].Rows.Count;
                while (flag)
                {
                    if (num == 0)
                    {
                        break;
                    }
                    int num3 = random.Next(num2);
                    string str14 = dataSet.Tables["IExamData"].Rows[num3]["ID"].ToString() + "#";
                    if (str9.IndexOf("#" + str14, 0) == -1)
                    {
                        str9 = str9 + str14;
                        num--;
                    }
                }
                dataSet.Tables.Clear();
                adapter.Dispose();
            }
            dataSet.Clear();
            dataSet.Dispose();
            selectConnection.Close();
            selectConnection.Dispose();
            string values = this.publicFun_0.GetValues("select top 1 RubricJ from PaperData where PaperID=" + this.int_0, "RubricJ");
            if (values != "")
            {
                values = values.Trim().Replace("_", "#");
            }
            else
            {
                values = "";
            }
            if (str.Length <= 1)
            {
                str = "";
            }
            else
            {
                str = str.Substring(1);
            }
            if (str2.Length <= 1)
            {
                str2 = "";
            }
            else
            {
                str2 = str2.Substring(1);
            }
            if (str3.Length <= 1)
            {
                str3 = "";
            }
            else
            {
                str3 = str3.Substring(1);
            }
            if (str4.Length <= 1)
            {
                str4 = "";
            }
            else
            {
                str4 = str4.Substring(1);
            }
            if (str5.Length > 1)
            {
                str5 = str5.Substring(1);
            }
            else
            {
                str5 = "";
            }
            if (str6.Length <= 1)
            {
                str6 = "";
            }
            else
            {
                str6 = str6.Substring(1);
            }
            if (str7.Length <= 1)
            {
                str7 = "";
            }
            else
            {
                str7 = str7.Substring(1);
            }
            if (str8.Length <= 1)
            {
                str8 = "";
            }
            else
            {
                str8 = str8.Substring(1);
            }
            if (str9.Length > 1)
            {
                str9 = str9.Substring(1);
            }
            else
            {
                str9 = "";
            }
            strSql = "Insert into PaperData(PaperID,UserCode,RubricS,RubricD,RubricB,RubricF,RubricA,RubricC,RubricT,RubricAN,RubricO,RubricJ,SortInfo) values(" + int_1;
            strSql = strSql + ",'" + string_1 + "','" + str + "','" + str2 + "','" + str3 + "','" + str4 + "','" + str5 + "','" + str6 + "','" + str7 + "','" + str8 + "','" + str9 + "','" + values + "','ID#ID#ID#ID#ID#ID#ID#ID#ID#ID')";
            this.publicFun_0.ExecuteSql(strSql);
        }

        private void method_6(int int_1, string string_0, string string_1, string string_2)
        {
            SqlDataReader reader;
            SqlCommand command;
            SqlConnection connection2;
            string str14;
            int count;
            int num3;
            string str = "#";
            string str2 = "#";
            string str3 = "#";
            string str4 = "#";
            string str5 = "#";
            string str6 = "#";
            string str7 = "#";
            string str8 = "#";
            string str9 = "#";
            Random random = new Random();
            bool flag = true;
            string str10 = "";
            int num = 0;
            string[] strArray = string_2.Split(new char[] { '#' });
            string strSql = "";
            string connectionString = ConfigurationManager.ConnectionStrings["Conn"].ConnectionString;
            SqlConnection selectConnection = new SqlConnection(connectionString);
            DataSet dataSet = new DataSet();
            if (Convert.ToInt32(strArray[0]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='A'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter9 = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter9 = new SqlDataAdapter(string_1 + "  and (" + str10 + ")", selectConnection);
                    adapter9.Fill(dataSet, "AExamData");
                    count = dataSet.Tables["AExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num == 0)
                        {
                            break;
                        }
                        num3 = random.Next(count);
                        str14 = dataSet.Tables["AExamData"].Rows[num3]["ID"].ToString() + "#";
                        if (str.IndexOf("#" + str14, 0) == -1)
                        {
                            str = str + str14;
                            num--;
                        }
                    }
                    adapter9.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            if (Convert.ToInt32(strArray[1]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='B'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter8 = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter8 = new SqlDataAdapter(string_1 + " and (" + str10 + ")", selectConnection);
                    adapter8.Fill(dataSet, "BExamData");
                    count = dataSet.Tables["BExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num == 0)
                        {
                            break;
                        }
                        num3 = random.Next(count);
                        str14 = dataSet.Tables["BExamData"].Rows[num3]["ID"].ToString() + "#";
                        if (str2.IndexOf("#" + str14, 0) == -1)
                        {
                            str2 = str2 + str14;
                            num--;
                        }
                    }
                    adapter8.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            if (Convert.ToInt32(strArray[2]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='C'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter7 = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter7 = new SqlDataAdapter(string_1 + " and (" + str10 + ")", selectConnection);
                    adapter7.Fill(dataSet, "CExamData");
                    count = dataSet.Tables["CExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num == 0)
                        {
                            break;
                        }
                        num3 = random.Next(count);
                        str14 = dataSet.Tables["CExamData"].Rows[num3]["ID"].ToString() + "#";
                        if (str3.IndexOf("#" + str14, 0) == -1)
                        {
                            str3 = str3 + str14;
                            num--;
                        }
                    }
                    adapter7.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            if (Convert.ToInt32(strArray[3]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='D'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter6 = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter6 = new SqlDataAdapter(string_1 + " and (" + str10 + ")", selectConnection);
                    adapter6.Fill(dataSet, "DExamData");
                    count = dataSet.Tables["DExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num == 0)
                        {
                            break;
                        }
                        num3 = random.Next(count);
                        str14 = dataSet.Tables["DExamData"].Rows[num3]["ID"].ToString() + "#";
                        if (str4.IndexOf("#" + str14, 0) == -1)
                        {
                            str4 = str4 + str14;
                            num--;
                        }
                    }
                    adapter6.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            if (Convert.ToInt32(strArray[4]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='E'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter5 = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter5 = new SqlDataAdapter(string_1 + " and (" + str10 + ")", selectConnection);
                    adapter5.Fill(dataSet, "EExamData");
                    count = dataSet.Tables["EExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num == 0)
                        {
                            break;
                        }
                        num3 = random.Next(count);
                        str14 = dataSet.Tables["EExamData"].Rows[num3]["ID"].ToString() + "#";
                        if (str5.IndexOf("#" + str14, 0) == -1)
                        {
                            str5 = str5 + str14;
                            num--;
                        }
                    }
                    adapter5.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            if (Convert.ToInt32(strArray[5]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='F'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter4 = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter4 = new SqlDataAdapter(string_1 + " and (" + str10 + ")", selectConnection);
                    adapter4.Fill(dataSet, "FExamData");
                    count = dataSet.Tables["FExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num == 0)
                        {
                            break;
                        }
                        num3 = random.Next(count);
                        str14 = dataSet.Tables["FExamData"].Rows[num3]["ID"].ToString() + "#";
                        if (str6.IndexOf("#" + str14, 0) == -1)
                        {
                            str6 = str6 + str14;
                            num--;
                        }
                    }
                    adapter4.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            if (Convert.ToInt32(strArray[6]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='G'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter3 = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter3 = new SqlDataAdapter(string_1 + " and (" + str10 + ")", selectConnection);
                    adapter3.Fill(dataSet, "GExamData");
                    count = dataSet.Tables["GExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num == 0)
                        {
                            break;
                        }
                        num3 = random.Next(count);
                        str14 = dataSet.Tables["GExamData"].Rows[num3]["ID"].ToString() + "#";
                        if (str7.IndexOf("#" + str14, 0) == -1)
                        {
                            str7 = str7 + str14;
                            num--;
                        }
                    }
                    adapter3.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            if (Convert.ToInt32(strArray[7]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='H'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter2 = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter2 = new SqlDataAdapter(string_1 + " and (" + str10 + ")", selectConnection);
                    adapter2.Fill(dataSet, "HExamData");
                    count = dataSet.Tables["HExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num == 0)
                        {
                            break;
                        }
                        num3 = random.Next(count);
                        str14 = dataSet.Tables["HExamData"].Rows[num3]["ID"].ToString() + "#";
                        if (str8.IndexOf("#" + str14, 0) == -1)
                        {
                            str8 = str8 + str14;
                            num--;
                        }
                    }
                    adapter2.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            if (Convert.ToInt32(strArray[8]) > 0)
            {
                connection2 = new SqlConnection(connectionString);
                connection2.Open();
                command = new SqlCommand("select RuleValue,GetNum from PaperRule where PaperID=" + int_1 + " and RubricType='I'", connection2);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                SqlDataAdapter adapter = null;
                while (reader.Read())
                {
                    str10 = reader["RuleValue"].ToString().Trim().Replace('‘', '\'').Replace("’", "'");
                    num = Convert.ToInt32(reader["GetNum"].ToString().Trim());
                    adapter = new SqlDataAdapter(string_1 + " and (" + str10 + ")", selectConnection);
                    adapter.Fill(dataSet, "IExamData");
                    count = dataSet.Tables["IExamData"].Rows.Count;
                    while (flag)
                    {
                        if (num == 0)
                        {
                            break;
                        }
                        num3 = random.Next(count);
                        str14 = dataSet.Tables["IExamData"].Rows[num3]["ID"].ToString() + "#";
                        if (str9.IndexOf("#" + str14, 0) == -1)
                        {
                            str9 = str9 + str14;
                            num--;
                        }
                    }
                    adapter.Dispose();
                    dataSet.Tables.Clear();
                }
                reader.Close();
                command.Dispose();
                connection2.Close();
                connection2.Dispose();
            }
            dataSet.Clear();
            dataSet.Dispose();
            selectConnection.Close();
            selectConnection.Dispose();
            string values = this.publicFun_0.GetValues("select top 1 RubricJ from PaperData where PaperID=" + this.int_0, "RubricJ");
            if (!(values != ""))
            {
                values = "";
            }
            else
            {
                values = values.Trim().Replace("_", "#");
            }
            if (str.Length > 1)
            {
                str = str.Substring(1);
            }
            else
            {
                str = "";
            }
            if (str2.Length <= 1)
            {
                str2 = "";
            }
            else
            {
                str2 = str2.Substring(1);
            }
            if (str3.Length <= 1)
            {
                str3 = "";
            }
            else
            {
                str3 = str3.Substring(1);
            }
            if (str4.Length <= 1)
            {
                str4 = "";
            }
            else
            {
                str4 = str4.Substring(1);
            }
            if (str5.Length <= 1)
            {
                str5 = "";
            }
            else
            {
                str5 = str5.Substring(1);
            }
            if (str6.Length <= 1)
            {
                str6 = "";
            }
            else
            {
                str6 = str6.Substring(1);
            }
            if (str7.Length > 1)
            {
                str7 = str7.Substring(1);
            }
            else
            {
                str7 = "";
            }
            if (str8.Length <= 1)
            {
                str8 = "";
            }
            else
            {
                str8 = str8.Substring(1);
            }
            if (str9.Length <= 1)
            {
                str9 = "";
            }
            else
            {
                str9 = str9.Substring(1);
            }
            strSql = "Insert into PaperData(PaperID,UserCode,RubricS,RubricD,RubricB,RubricF,RubricA,RubricC,RubricT,RubricAN,RubricO,RubricJ,SortInfo) values(" + int_1;
            strSql = strSql + ",'" + string_0 + "','" + str + "','" + str2 + "','" + str3 + "','" + str4 + "','" + str5 + "','" + str6 + "','" + str7 + "','" + str8 + "','" + str9 + "','" + values + "','ID#ID#ID#ID#ID#ID#ID#ID#ID#ID')";
            this.publicFun_0.ExecuteSql(strSql);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            this.httpCookie_0 = new HttpCookie("ExamUserCode");
            this.httpCookie_0 = base.Request.Cookies["ExamUserCode"];
            this.httpCookie_1 = new HttpCookie("ExamUserName");
            this.httpCookie_1 = base.Request.Cookies["ExamUserName"];
            this.httpCookie_2 = new HttpCookie("ExamUserLevel");
            this.httpCookie_2 = base.Request.Cookies["ExamUserLevel"];
            this.httpCookie_3 = new HttpCookie("ExamDeptID");
            this.httpCookie_3 = base.Request.Cookies["ExamDeptID"];
            this.int_0 = Convert.ToInt32(base.Request["ID"].ToString());
            if ((this.httpCookie_0 == null) || (this.httpCookie_0.Value == ""))
            {
                base.Response.Write("<script language=javascript>top.location.href='../Index.htm';self.close();</script>");
            }
            else
            {
                base.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                base.Response.Cache.SetNoStore();
                this.httpCookie_0.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_0.Value));
                this.httpCookie_1.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_1.Value));
                this.httpCookie_2.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_2.Value));
                this.httpCookie_3.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_3.Value));
                if (!base.IsPostBack)
                {
                    this.ViewState["strRubric"] = "";
                    this.Page.Title = ConfigurationManager.ConnectionStrings["ProTitle"].ConnectionString;
                    if (this.publicFun_0.ReturnPaperData() == "Yes")
                    {
                        if (!(this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='HandComb'", "ParmValue") == "1"))
                        {
                            this.CBHandSet.Enabled = false;
                        }
                        else
                        {
                            this.CBHandSet.Enabled = true;
                        }
                        this.txtStartDate.Text = DateTime.Now.ToString("yyyy-MM-dd");
                        this.txtEndDate.Text = DateTime.Now.AddDays(1.0).ToString("yyyy-MM-dd");
                        SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
                        connection.Open();
                        SqlCommand command = new SqlCommand("select AddPaper,ManagPaper from UserPower where UserCode='" + this.httpCookie_0.Value + "'", connection);
                        SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                        if (reader.Read())
                        {
                            this.ViewState["AddPower"] = reader["AddPaper"].ToString();
                            this.ViewState["ManagPower"] = reader["ManagPaper"].ToString();
                        }
                        reader.Close();
                        command.Dispose();
                        connection.Close();
                        connection.Dispose();
                        if (this.ViewState["ManagPower"].ToString() == "Y")
                        {
                            this.butEnter.Visible = true;
                        }
                        else if (!(this.ViewState["AddPower"].ToString() == "Y"))
                        {
                            this.butEnter.Visible = false;
                        }
                        else if (this.publicFun_0.GetValues("select InputUserCode from PaperInfo where ID=" + this.int_0, "InputUserCode") == this.httpCookie_0.Value)
                        {
                            this.butEnter.Visible = true;
                        }
                        else
                        {
                            this.butEnter.Visible = false;
                        }
                        this.butEnter.Attributes.Add("onclick", @"javascript:{if(confirm('确认补录参考人员无误？\n生成试卷需要一定的时间，请耐心等待生成结果！\n\n请勿离开此页面！！！')==false) return false;}");
                        if ((this.int_0 != 0) && (this.httpCookie_2.Value != "A"))
                        {
                            this.method_0();
                            this.method_1();
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCheck", "alert('此版本暂未授权,请拔打(0)13870606104手机号进行授权！')", true);
                    }
                }
            }
        }

        protected void RBLLastExamUser_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.method_1();
            ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "Render", "LayaUIFormRender();", true);
        }
    }
}

